﻿@using Coralcode.Base.Utils
@using CoralNode.Core.Entity.Domains.Bookmark
@using CoralNode.Core.Entity.Enums.Bookmark
@model CoralNode.Core.Entity.SearchQuerys.Bookmark.BookmarkSearchQuery
@{
    ViewBag.PagerList = ViewBag.Bookmarks;
    ViewBag.queryString = EntityUtil.ToQueryString(Model);
    ViewBag.PagerUrl = "/m/bookmark/listbookmark";
}

<!--content-->
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">网络收藏&nbsp;&nbsp;/&nbsp;&nbsp;网络收藏管理</span>
        </div>
        <div id="main">
            <div class="content_tab extra_normal">
                <div class="tablist extra_normal">
                </div>
            </div>
            <div class="js_tabcnt">
                <div class="tablelist_style1" data-js="tabellist_style1">
                    <div class="funsearch p_1 pl_2 pr_2 extra_normal">
                        <span class="t_des f_l pt_0-5">状态：</span>
                        <div class="select_owner w_12-5 " data-meta="{value:'@Model.State', btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>'}">
                            <ul>
                                @foreach (var item in @ViewBag.StateList) {
                                    if (@item.Value == @Model.State) {
                                        <li data-value="@item.Value"><a class="current" href="/m/bookmark/listbookmark?state=@item.Value">@item.Key</a>
                                        </li>
                                    } else {
                                        <li data-value="@item.Value"><a href="/m/bookmark/listbookmark?state=@item.Value">@item.Key</a>
                                        </li>
                                    }
                                }
                            </ul>
                        </div>
                        <div class="f_r">
                            <form method="POST" action="/m/bookmark/listbookmark">
                                <span class="t_des f_l pt_0-5">标签名称：</span>
                                <label class="search f_l">
                                    @Html.TextBoxFor(m => m.Tag, new { @class = "text w_18", @msg = "请输入关键字" })
                                    @Html.AntiForgeryToken()
                                    <input type="submit" value="" class="submit" /></label>
                            </form>
                        </div>
                    </div>
                    <table cellpadding="0" cellspacing="0">
                        <tr class="exclude">
                            <th width="60">选择</th>
                            <th width="50" align="left">ID</th>
                            <th align="left">名称</th>
                            <th width="60">状态</th>
                            <th width="140">操作</th>
                        </tr>
                        @foreach (BookmarkDomain item in ViewBag.Bookmarks.Items)
                        {
                            <tr>
                                <td>
                                    <label class="checkbox_own">
                                        <input type="checkbox" value="@item.Id"/></label></td>
                                <td class="td_left">@item.Id</td>
                                <td class="td_left">
                                    <a href="@item.Url">@item.Title</a>
                                </td>
                                <td class="js_state">@EnumUtil.GetEnumDescription(BookmarkStateEnums.GetInstance(),item.State)
                                </td>
                                <td>
                                    @foreach (var state in ViewBag.StateList)
                                    {
                                        if (state.Value > 0)
                                        {
                                            if (state.Value == item.State)
                                            {
                                                <a class="js_changestateaction" style="display: none;" href="/m/bookmark/changestate/@item.Id?state=@state.Value">@state.Key</a>
                                            }
                                            else
                                            {
                                                <a class="js_changestateaction" href="/m/bookmark/changestate/@item.Id?state=@state.Value">@state.Key</a>
                                            }
                                        }
                                    }
                                </td>
                            </tr>
                        }
                    </table>
                    <div class="global_fun ">
                        <label class="checkbox_own gloabal_select">
                            <input type="checkbox" /></label>
                        <input type="button" class="btn_4 btn invert" value="反选" /><input type="button" class="btn_4 btn reset"
                                                                                          value="重置" />
                        <a href="/m/bookmark/delete" class="js_delete">删除</a>
                    </div>
                </div>
            </div>
        </div>
        @Html.IncludePage("CoralAdmin/Shared","Pager")
    </div>
</div>
<script type="text/javascript">
    $(function() {
        $(".js_changestateaction").live("click", function (e) {
            e.preventDefault();
            var $this = $(this);
            var href = $this.attr("href");
            $.post(href, function (result) {
                if (result.Type == 5) {
                    $this.hide();
                    $this.siblings(".js_changestateaction").show();
                    $this.parents("tr").find("td.js_state").text($this.text());
                } else {
                    alert("改变失败！");
                }
            });
        });
    });
</script>